<?php

namespace app\admin\model;

use app\lib\exception\ParameterException;

class User extends Base
{

    public static function getByOpenID($openid){
        return self::where('openId',$openid)->find();
    }

    public static function getopenId($userId){
        $user = self::get($userId);
        if($user && $user->openId){
            return $user->openId;
        }else{
            throw new ParameterException([
                'msg' => '用户异常'
            ]);
        }
    }
}